﻿using System;
using UniFramework.RedPoint;
using UnityEngine;

namespace RedPointSystem.Sample
{
	public class Sample : MonoBehaviour
	{
		private UniRedPointSystem _redPointSystem;

		private void Start()
		{
			_redPointSystem = new UniRedPointSystem();
			_redPointSystem.CreateTreeNode(ERedPointType.Test1, ERedPointType.Null);
			_redPointSystem.CreateTreeNode(ERedPointType.Test2, ERedPointType.Test1);
			RedPointTreeNode redPointTreeNode3 =
				_redPointSystem.CreateTreeNode(ERedPointType.Test3, ERedPointType.Test1);
			// redPointTreeNode3.OnNodeActiveValueChange += (treeNode,isActive) =>
			// {
			//     Debug.Log("Test3:" + isActive);
			// };
		}

		private void OnDestroy()
		{
			_redPointSystem.Dispose();
			_redPointSystem = null;
		}

		private void Update()
		{
			if (Input.GetKeyDown(KeyCode.A))
			{
				var redPointTreeNode = _redPointSystem.GetTreeNode(ERedPointType.Test2);
				redPointTreeNode.ChangeNodeState(true);
				var redPointTreeNode3 = _redPointSystem.GetTreeNode(ERedPointType.Test3);
				redPointTreeNode3.ChangeNodeState(true);
			}

			if (Input.GetKeyDown(KeyCode.B))
			{
				var redPointTreeNode = _redPointSystem.GetTreeNode(ERedPointType.Test2);
				redPointTreeNode.ChangeNodeState(true);
			}

			if (Input.GetKeyDown(KeyCode.C))
			{
				var redPointTreeNode = _redPointSystem.GetTreeNode(ERedPointType.Test3);
				redPointTreeNode.ChangeNodeState(true);
			}

			if (Input.GetKeyDown(KeyCode.D))
			{
				var redPointTreeNode = _redPointSystem.GetTreeNode(ERedPointType.Test2);
				redPointTreeNode.ChangeNodeState(false);
			}

			if (Input.GetKeyDown(KeyCode.E))
			{
				var redPointTreeNode = _redPointSystem.GetTreeNode(ERedPointType.Test3);
				redPointTreeNode.ChangeNodeState(false);
			}
		}
	}
}